<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>

  <script>
    // 已知字符串  
    //  将参数名和参数值转化成对象的键值对的形式  {name :”zhangsan” ,  age:”18” , classNO:”090728”}
    var str = "name=zhangsan&age=18&classNo=090728&a=1"

    function add(mystr) {
      var obj = {}
      var arr = mystr.split("&");
      for (var i = 0; i < arr.length; i++) {
        var newarr = arr[i].split("=");
        console.log(newarr)
        obj[newarr[0]] = newarr[1]
      }
      return obj
    }

    console.log(add(str))

  </script>

</body>

</html>